﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace testqwe
{
    //平行四边形条带
    class Stripe
    {
        int diameter;
        int longLength;
        int row;
        double initlength;
        public double[] width;
         public  int[,] u;
        public Stripe(int d,int l)
        {
            diameter = d;
            longLength = l;
            row = Constant.ROW;
            initlength = 2 * Constant.THIRD_OF_SQRT_THREE * (d+Constant.Allowance);
            width = new double[row];
            setwidth();
            u = new int[row, l + 1];
            generate();
        }

        //生成条带包含的信息，即条带中包含有多少个毛坯
        private void generate()
        {
            //int init=(int)initlenght;
            int d = diameter + Constant.Allowance;
            for (int i = 0; i <= longLength; i++)
            {
                int n = 0;
                if (i >= initlength)
                {
                    n = (int)((i - initlength) / d) + 1;
                    if ((int)(i - initlength) % d == 0)
                    {
                      int ss=Constant.nomalLength.Count;
                      Constant.nomalLength.Add(i);
                      for (int len = 0; len < ss; len++)
                      {
                          if (Constant.nomalLength[len] == i)
                          {
                              Constant.nomalLength.RemoveAt(ss);
                              break; 
                          }
                      }
                          
                    }
                }
                for (int j = 0; j < row; j++)
                {
                    u[j, i] = n * (j+1);
                }
            }
        }

        //计算条带宽度
        private void setwidth()
        {
            int d = diameter + Constant.Allowance;
            for (int i = 0; i < row; i++)
            {  
                width[i] = (d + d * Constant.SQRT_THREE * i / 2) * Constant.THIRD_OF_SQRT_THREE * 2;
            }
        }

    }
}
